import requests
from common.get_token import GetToken


#API封装
import requests


class IhrmAddDepart:
    token = GetToken.get_token()
    #添加部门
    @classmethod
    def add_depart(cls,body):
        url = "http://ihrm2-test.itheima.net/api/company/department"
        headers = {"Content-Type":"application/json","Authorization":cls.token}
        resp = requests.post(url=url,headers=headers,json=body)
        return resp
    #修改(Revise)部门
    @classmethod
    def revise_depart(cls,id,body):
        url = f"http://ihrm2-test.itheima.net/api/company/department/{id}"
        headers = {"Content-Type":"application/json","Authorization":cls.token}
        resp = requests.put(url=url,headers=headers,json=body)
        return resp
    #删除部门
    @classmethod
    def delete_depart(cls,id):
        url = f"http://ihrm2-test.itheima.net/api/company/department/{id}"
        headers = {"Authorization":cls.token}
        resp = requests.delete(url=url,headers=headers)
        return resp
    #查看部门
    @classmethod
    def view_depart(cls,id):
        url = f"http://ihrm2-test.itheima.net/api/company/department/{id}"
        headers = {"Content-Type": "application/json", "Authorization": cls.token}
        resp = requests.get(url=url,headers=headers)
        return resp